package com.balance.anole.client.retail.payment;

import java.math.BigDecimal;

import com.balance.anole.common.to.CodeLookTO;
import com.balance.anole.utils.Constants;

public class CouponPayment extends Payment {

	public CouponPayment(BigDecimal paid, BigDecimal needPay) {
		super(paid, needPay);
		setPaymentMode(new CodeLookTO(Constants.CODE_TYPE_PAYMENT_TYPE, "V"));
	}

	public BigDecimal pay(){
		BigDecimal change = paid.subtract(needPay);
		//if coupon value is more than required, no change will return;
		return change.signum() <= 0? change : BigDecimal.ZERO;
	}

	public int getPriority(){
		return 1;
	}

	@Override
	public String getPaymentDesc() {
		return "Coupon";
	}

	@Override
	public BigDecimal getRealPaidValue() {
		//Coupon: no change.
		return paid;
	}
}
